using System.ComponentModel.Composition;
using OrbitOne.CRMLyncInfoDashboard.CRM.OrganizationData;

namespace OrbitOne.CRMLyncInfoDashboard.CRM.OData
{
    [Export(typeof(ICrmDataProvider))]
    public class CrmLeadDataProvider : CrmDataProvider<Lead, LeadModel>, ICrmLeadDataProvider
    {
        [ImportingConstructor]
        public CrmLeadDataProvider(IPredicateBuilder predicateBuilder,
            ICrmLeadMetadataProvider crmLeadMetadataProvider,
            IClientScript clientScript) 
            : base(predicateBuilder, 
            crmLeadMetadataProvider, 
            clientScript)
        {
        }

        protected override string[] GetSearchValues(Lead entity)
        {
            return new[]{
                           (entity.Telephone1 ?? "").CleanupNonAlphanumeric(m_phoneNumberCleanup),
                           (entity.Telephone2 ?? "").CleanupNonAlphanumeric(m_phoneNumberCleanup),
                           (entity.MobilePhone ?? "").CleanupNonAlphanumeric(m_phoneNumberCleanup),
                           (entity.EMailAddress1 ?? "")
                       };
        }

        protected override string LyncSearchFieldResourceName
        {
            get { return "LeadLyncSearchField"; }
        }
    }
}